package cn.core.coding.service;

import cn.core.coding.ao.ProConfAO;
import cn.core.coding.ao.ProConfAndDbTableConfAO;
import cn.core.coding.eo.DbTableConf;
import cn.core.coding.eo.ProjectModule;
import cn.core.coding.mapper.DbTableConfMapper;
import cn.core.coding.mapper.ProjectModuleMapper;
import cn.core.coding.qo.DbTableConfQO;
import cn.core.coding.qo.ProjectModuleQO;
import cn.core.coding.vo.*;
import cn.core.tool.context.CoreContextData;
import cn.core.tool.exception.CoreException;
import cn.core.tool.util.CoreTool;
import cn.core.tool.util.CoreTree;
import cn.core.tool.util.Paging;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.creator.HikariDataSourceCreator;
import com.baomidou.dynamic.datasource.ds.ItemDataSource;
import com.baomidou.dynamic.datasource.enums.SeataMode;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.hikari.HikariCpConfig;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.sql.DataSource;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;

/**
 * 生成代码 服务
 */
@Log4j2
@Service
public class CodingService {

  @Resource
  private GetDbInfoService getDbInfoService;

  @Resource
  private ProjectModuleMapper projectModuleMapper;

  @Resource
  private DataSource dataSource;

  @Resource
  private DbTableConfMapper dbTableConfMapper;

  /**
   * 动态添加当前账号对应项目模块的数据源
   */
  public void addDataSource(String projectModuleId) throws Exception {
    try {
      if (CoreTool.isNullStr(projectModuleId)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      ProjectModule projectModule = projectModuleMapper.pk(new ProjectModuleQO().setId(projectModuleId));
      String poolName = CoreContextData.getCurrentContextData().getAccount() + projectModule.getProjectModuleName().replaceAll("-", "");
      String driverClassName = null;
      String urlStr = null;
      if (CoreTool.mysql.equals(projectModule.getDbType())) {
        driverClassName = "com.mysql.cj.jdbc.Driver";
        urlStr = "jdbc:mysql://" + projectModule.getIpAddress() + ":" + projectModule.getPort() + "/" + projectModule.getDbName() + "?useUnicode=yes&characterEncoding=utf8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true&allowMultiQueries=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true";
      } else if (CoreTool.oracle.equals(projectModule.getDbType())) {
        driverClassName = "oracle.jdbc.driver.OracleDriver";
        urlStr = "jdbc:oracle:thin:@" + projectModule.getIpAddress() + ":" + projectModule.getPort() + "/" + projectModule.getServerName();
      } else {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
//      if (ds.getCurrentDataSources().containsKey(poolName)) {
//        throw new CoreException("数据源已经加载，请不要重复加载！");
//      }
      DataSourceProperty dataSourceProperty = new DataSourceProperty();
      dataSourceProperty.setPoolName(poolName);
      dataSourceProperty.setDriverClassName(driverClassName);
      dataSourceProperty.setUrl(urlStr);
      dataSourceProperty.setUsername(projectModule.getUsername());
      dataSourceProperty.setPassword(projectModule.getPassword());
      dataSourceProperty.setLazy(false);
      HikariCpConfig hikariCpConfig = new HikariCpConfig();
      hikariCpConfig.setMinIdle(1);
      hikariCpConfig.setMaxPoolSize(5);
      DataSource newDataSource = new HikariDataSourceCreator(hikariCpConfig).createDataSource(dataSourceProperty);
      ItemDataSource newItemDataSource = new ItemDataSource(poolName, newDataSource, newDataSource, false, false, SeataMode.AT);
      ds.addDataSource(poolName, newItemDataSource);
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 获取数据库所有表信息
   */
  public Collection<DbTablesInfoVO> getDbAllTablesInfo(String projectModuleId) throws Exception {
    try {
      if (CoreTool.isNullStr(projectModuleId)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      ProjectModule projectModule = projectModuleMapper.pk(new ProjectModuleQO().setId(projectModuleId));
      String poolName = CoreContextData.getCurrentContextData().getAccount() + projectModule.getProjectModuleName().replaceAll("-", "");
      DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
      if (!ds.getCurrentDataSources().containsKey(poolName)) {
        throw new CoreException("数据源未加载，请先加载数据源！");
      }
      if (CoreTool.mysql.equals(projectModule.getDbType())) {
        return getDbInfoService.getMysqlDbAllTablesInfoByDbName(poolName, projectModule.getDbName());
      } else if (CoreTool.oracle.equals(projectModule.getDbType())) {
        return getDbInfoService.getOracleDbAllTablesInfo(poolName);
      } else {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 数据库表配置 >>> 批量保存或修改
   */
  @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
  public Collection<DbTableConf> batchSaveOrUpdateDbTableConf(Collection<DbTableConf> eos) throws Exception {
    try {
      if (CoreTool.isEmpty(eos)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      LinkedHashSet<DbTableConf> saveDbTableConfSet = new LinkedHashSet<>();
      LinkedHashSet<DbTableConf> upDbTableConfSet = new LinkedHashSet<>();
      LinkedHashSet<DbTableConf> rDbTableConfSet = new LinkedHashSet<>();
      for (DbTableConf eo : eos) {
        if (CoreTool.isNullStr(eo.getId())) {
          eo.setId(CoreTool.getUUID32());
          saveDbTableConfSet.add(eo);
        } else {
          upDbTableConfSet.add(eo);
        }
      }
      if (CoreTool.isNotEmpty(saveDbTableConfSet)) {
        dbTableConfMapper.saveBatch(new Paging<>(), saveDbTableConfSet);
        rDbTableConfSet.addAll(saveDbTableConfSet);
      }
      if (CoreTool.isNotEmpty(upDbTableConfSet)) {
        dbTableConfMapper.updateBatch(new Paging<>(), upDbTableConfSet);
        rDbTableConfSet.addAll(upDbTableConfSet);
      }
      return rDbTableConfSet;
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 获取项目模块数据库表配置树
   */
  public CoreTree<?> getProjectModuleDbTableConfTreeData(String projectModuleId) throws Exception {
    try {
      if (CoreTool.isNullStr(projectModuleId)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      ProjectModule projectModule = projectModuleMapper.pk(new ProjectModuleQO().setId(projectModuleId));
      String poolName = CoreContextData.getCurrentContextData().getAccount() + projectModule.getProjectModuleName().replaceAll("-", "");
      DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
      if (!ds.getCurrentDataSources().containsKey(poolName)) {
        throw new CoreException("数据源未加载，请先加载数据源！");
      }
      CoreTree<?> tree = null;
      Collection<CoreTree<?>> treeSet = new ArrayList<>();
      treeSet.add(new CoreTree<ProjectModule>(projectModule)
          .setId(projectModule.getId())
          .setKey(projectModule.getId())
          .setName(projectModule.getProjectModuleName())
          .setTkey("ProjectModule")
          .setTitle(projectModule.getProjectModuleNotes() + " - " + projectModule.getProjectModuleName())
          .setValue(projectModule.getId()));
      Collection<DbTableConf> dbTableConfSet = dbTableConfMapper.query(new DbTableConfQO().setFkid(projectModule.getId()).setWeightOrderAsc("y"));
      if (CoreTool.isNotEmpty(dbTableConfSet)) {
        for (DbTableConf eo : dbTableConfSet) {
          treeSet.add(new CoreTree<DbTableConf>(eo)
              .setId(eo.getId())
              .setKey(eo.getId())
              .setName(eo.getTableName())
              .setTkey("DbTableConf")
              .setTitle(eo.getTableName() + " - " + eo.getTableNameAnnotation())
              .setValue(eo.getId())
              .setPid(eo.getFkid()));
        }
      }
      tree = CoreTool.toTree(treeSet, true);
      return tree;
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 项目配置和数据库表配置 >>> 设置参数
   */
  public ProConfAndDbTableConfAO toProConfAndDbTableConfParam(ProjectModule projectModule, DbTableConf dbTableConf) throws Exception {
    try {
      String poolName = CoreContextData.getCurrentContextData().getAccount() + projectModule.getProjectModuleName().replaceAll("-", "");
      return new ProConfAndDbTableConfAO()
          .setCodeCi(projectModule.getCodeCi())
          .setProjectPath(projectModule.getProjectPath())
          .setProjectPathVue(projectModule.getProjectPathVue())
          .setProjectModuleName(projectModule.getProjectModuleName())
          .setDbType(projectModule.getDbType())
          .setDbTablePrefix(dbTableConf.getDbTablePrefix().toUpperCase())
          .setDsName(poolName)
          .setDbName(projectModule.getDbName())
          .setTableName(dbTableConf.getTableName());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 获取项目模块配置
   */
  public ProjectModuleConfVO getProjectModuleConf(ProConfAO proConfParam) throws Exception {
    try {
      if (CoreTool.isNullEo(proConfParam)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      ProjectModuleConfVO projectModuleConfVO = new ProjectModuleConfVO();
      projectModuleConfVO.setCodeCi(proConfParam.getCodeCi());
      projectModuleConfVO.setProjectPath(proConfParam.getProjectPath());
      projectModuleConfVO.setProjectPathVue(proConfParam.getProjectPathVue());
      projectModuleConfVO.setProjectPathUni(proConfParam.getProjectPathUni());
      projectModuleConfVO.setProjectModuleName(proConfParam.getProjectModuleName());
      projectModuleConfVO.setProjectModuleNotes(proConfParam.getProjectModuleNotes());
      projectModuleConfVO.setConfMap(CoreCodingConf.getConfMap(projectModuleConfVO.getCodeCi()));
      projectModuleConfVO.setProjectModuleNameSet(CoreCodingConf.getProjectModuleNameSet(projectModuleConfVO.getProjectModuleName()));
      projectModuleConfVO.setProjectModulePomFilePath(CoreCodingConf.getProjectModulePomFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setProjectModuleGitignoreFilePath(CoreCodingConf.getProjectModuleGitignoreFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setCodeFileReadmeFilePath(CoreCodingConf.getCodeFileReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setResourcesFileReadmeFilePath(CoreCodingConf.getResourcesFileReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setJavaJdbcEntityReadmeFilePath(CoreCodingConf.getJavaJdbcEntityReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setMapperReadmeFilePath(CoreCodingConf.getMapperReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setParamReadmeFilePath(CoreCodingConf.getParamReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setBussReadmeFilePath(CoreCodingConf.getBussReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setQueryReadmeFilePath(CoreCodingConf.getQueryReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setRestReadmeFilePath(CoreCodingConf.getRestReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setServiceInterfacesReadmeFilePath(CoreCodingConf.getServiceInterfacesReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setServiceImplementReadmeFilePath(CoreCodingConf.getServiceImplementReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setServiceReadmeFilePath(CoreCodingConf.getServiceReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setVoReadmeFilePath(CoreCodingConf.getVoReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      projectModuleConfVO.setMappingReadmeFilePath(CoreCodingConf.getMappingReadmeFilePath(projectModuleConfVO.getProjectPath(), projectModuleConfVO.getProjectModuleName(), projectModuleConfVO.getProjectModuleNameSet()));
      return projectModuleConfVO;
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成项目模块
   */
  public void generateProjectModule(ProjectModuleConfVO projectModuleConfVO) throws Exception {
    try {
      if (CoreTool.isNullEo(projectModuleConfVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(projectModuleConfVO.getConfMap());
      configMap.put("projectsModulesName", projectModuleConfVO.getProjectModuleName());
      configMap.put("projectsModulesNotes", projectModuleConfVO.getProjectModuleNotes());
      CoreTool.getFileByContentStrAndPath(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/project/1.txt"), configMap), projectModuleConfVO.getProjectModulePomFilePath());
      CoreTool.getFileByContentStrAndPath(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/git/1.txt"), new LinkedHashMap<String, String>()), projectModuleConfVO.getProjectModuleGitignoreFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getCodeFileReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getResourcesFileReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getJavaJdbcEntityReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getMapperReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getParamReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getBussReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getQueryReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getRestReadmeFilePath());
//      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getServiceInterfacesReadmeFilePath());
//      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getServiceImplementReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getServiceReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getVoReadmeFilePath());
      CoreTool.getFileByContentStrAndPath(CoreCodingConf.readmeContent, projectModuleConfVO.getMappingReadmeFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 获取数据库表配置和信息
   */
  public DbTableConfAndInfoVO getDbTableConfAndInfo(ProConfAndDbTableConfAO proConfAndDbTableConfParam) throws Exception {
    try {
      if (CoreTool.isNullEo(proConfAndDbTableConfParam)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      if (CoreTool.isNullStr(proConfAndDbTableConfParam.getDbType())) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      DbTableConfAndInfoVO dbTableConfAndInfoVO = new DbTableConfAndInfoVO();
      dbTableConfAndInfoVO.setCodeCi(proConfAndDbTableConfParam.getCodeCi());
      dbTableConfAndInfoVO.setProjectPath(proConfAndDbTableConfParam.getProjectPath());
      dbTableConfAndInfoVO.setProjectPathVue(proConfAndDbTableConfParam.getProjectPathVue());
      dbTableConfAndInfoVO.setProjectPathUni(proConfAndDbTableConfParam.getProjectPathUni());
      dbTableConfAndInfoVO.setProjectModuleName(proConfAndDbTableConfParam.getProjectModuleName());
      dbTableConfAndInfoVO.setDbTablePrefix(proConfAndDbTableConfParam.getDbTablePrefix());
      if (CoreTool.mysql.equals(proConfAndDbTableConfParam.getDbType())) {
        MysqlDbTableInfoVO mysqlDbTableInfoVO = getDbInfoService.getMysqlDbTableInfo(proConfAndDbTableConfParam.getDsName(), proConfAndDbTableConfParam.getDbName(), proConfAndDbTableConfParam.getTableName());
        Collection<MysqlDbTableColInfoVO> mysqlDbTableColInfoVOSet = getDbInfoService.getMysqlDbTableColInfo(proConfAndDbTableConfParam.getDsName(), proConfAndDbTableConfParam.getDbName(), proConfAndDbTableConfParam.getTableName());
        MysqlDbTablePkInfoVO mysqlDbTablePkInfoVO = getDbInfoService.getMysqlDbTablePkInfo(proConfAndDbTableConfParam.getDsName(), proConfAndDbTableConfParam.getDbName(), proConfAndDbTableConfParam.getTableName());
        dbTableConfAndInfoVO.setConfMap(CoreCodingConf.getConfMap(dbTableConfAndInfoVO.getCodeCi()));
        dbTableConfAndInfoVO.setProjectModuleNameSet(CoreCodingConf.getProjectModuleNameSet(dbTableConfAndInfoVO.getProjectModuleName()));
        DbTableInfoVO dbTableInfoVO = new DbTableInfoVO();
        dbTableInfoVO.setDbTableName(mysqlDbTableInfoVO.getTableName().toUpperCase());
        dbTableInfoVO.setDbTableNameAnnotation(mysqlDbTableInfoVO.getTableComment());
        dbTableInfoVO.setInitialCaseEntityName(CoreTool.isNotNullStr(dbTableConfAndInfoVO.getDbTablePrefix()) ? CoreTool.getInitialCaseHumpByUnderline(dbTableInfoVO.getDbTableName().replaceAll(dbTableConfAndInfoVO.getDbTablePrefix(), "").trim()) : CoreTool.getInitialCaseHumpByUnderline(dbTableInfoVO.getDbTableName()));
        dbTableInfoVO.setInitialLowercaseEntityName(CoreTool.isNotNullStr(dbTableConfAndInfoVO.getDbTablePrefix()) ? CoreTool.getInitialLowercaseHumpByUnderline(dbTableInfoVO.getDbTableName().replaceAll(dbTableConfAndInfoVO.getDbTablePrefix(), "").trim()) : CoreTool.getInitialLowercaseHumpByUnderline(dbTableInfoVO.getDbTableName()));
        dbTableConfAndInfoVO.setDbTableInfoVO(dbTableInfoVO);
        Collection<DbTableColInfoVO> dbTableColInfoVOSet = new LinkedHashSet<>();
        for (MysqlDbTableColInfoVO mysqlDbTableColInfoVO : mysqlDbTableColInfoVOSet) {
          DbTableColInfoVO dbTableColInfoVO = new DbTableColInfoVO();
          dbTableColInfoVO.setColName(mysqlDbTableColInfoVO.getColumnName().toUpperCase());
          dbTableColInfoVO.setColNameAnnotation(mysqlDbTableColInfoVO.getColumnComment());
          dbTableColInfoVO.setJavaDataType(CoreCodingConf.getJavaDataType(mysqlDbTableColInfoVO.getDataType()));
          dbTableColInfoVO.setTsDataType(CoreCodingConf.getTsDataType(mysqlDbTableColInfoVO.getDataType()));
          dbTableColInfoVO.setIsNull(CoreCodingConf.getIsNull(mysqlDbTableColInfoVO.getIsNullable()));
          dbTableColInfoVO.setInitialCaseColumnName(CoreTool.getInitialCaseHumpByUnderline(dbTableColInfoVO.getColName()));
          dbTableColInfoVO.setInitialLowercaseColumnName(CoreTool.getInitialLowercaseHumpByUnderline(dbTableColInfoVO.getColName()));
          dbTableColInfoVO.setWeightOrder(mysqlDbTableColInfoVO.getOrdinalPosition());
          dbTableColInfoVOSet.add(dbTableColInfoVO);
        }
        dbTableConfAndInfoVO.setDbTableColInfoVOSet(dbTableColInfoVOSet);
        DbTablePkInfoVO dbTablePkInfoVO = new DbTablePkInfoVO();
        dbTablePkInfoVO.setColName(mysqlDbTablePkInfoVO.getColumnName().toUpperCase());
        for (DbTableColInfoVO dbTableColInfoVO : dbTableColInfoVOSet) {
          if (dbTablePkInfoVO.getColName().equals(dbTableColInfoVO.getColName())) {
            dbTablePkInfoVO.setColNameAnnotation(dbTableColInfoVO.getColNameAnnotation());
            dbTablePkInfoVO.setJavaDataType(dbTableColInfoVO.getJavaDataType());
            dbTablePkInfoVO.setTsDataType(dbTableColInfoVO.getTsDataType());
            dbTablePkInfoVO.setIsNull(dbTableColInfoVO.getIsNull());
            dbTablePkInfoVO.setInitialCaseColumnName(dbTableColInfoVO.getInitialCaseColumnName());
            dbTablePkInfoVO.setInitialLowercaseColumnName(dbTableColInfoVO.getInitialLowercaseColumnName());
            dbTablePkInfoVO.setWeightOrder(dbTableColInfoVO.getWeightOrder());
            break;
          }
        }
        dbTableConfAndInfoVO.setDbTablePkInfoVO(dbTablePkInfoVO);
      } else if (CoreTool.oracle.equals(proConfAndDbTableConfParam.getDbType())) {
        OracleDbTableInfoVO oracleDbTableInfoVO = getDbInfoService.getOracleDbTableInfo(proConfAndDbTableConfParam.getDsName(), proConfAndDbTableConfParam.getTableName());
        Collection<OracleDbTableColInfoVO> oracleDbTableColInfoVOSet = getDbInfoService.getOracleDbTableColInfo(proConfAndDbTableConfParam.getDsName(), proConfAndDbTableConfParam.getTableName());
        String primaryKeyConstraintName = getDbInfoService.getOracleDbTablePrimaryKeyConstraintName(proConfAndDbTableConfParam.getDsName(), proConfAndDbTableConfParam.getTableName());
        OracleDbTablePkInfoVO oracleDbTablePkInfoVO = getDbInfoService.getOracleDbTablePkInfo(proConfAndDbTableConfParam.getDsName(), proConfAndDbTableConfParam.getTableName(), primaryKeyConstraintName);
        dbTableConfAndInfoVO.setConfMap(CoreCodingConf.getConfMap(dbTableConfAndInfoVO.getCodeCi()));
        dbTableConfAndInfoVO.setProjectModuleNameSet(CoreCodingConf.getProjectModuleNameSet(dbTableConfAndInfoVO.getProjectModuleName()));
        DbTableInfoVO dbTableInfoVO = new DbTableInfoVO();
        dbTableInfoVO.setDbTableName(oracleDbTableInfoVO.getTableName().toUpperCase());
        dbTableInfoVO.setDbTableNameAnnotation(oracleDbTableInfoVO.getComments());
        dbTableInfoVO.setInitialCaseEntityName(CoreTool.isNotNullStr(dbTableConfAndInfoVO.getDbTablePrefix()) ? CoreTool.getInitialCaseHumpByUnderline(dbTableInfoVO.getDbTableName().replaceAll(dbTableConfAndInfoVO.getDbTablePrefix(), "").trim()) : CoreTool.getInitialCaseHumpByUnderline(dbTableInfoVO.getDbTableName()));
        dbTableInfoVO.setInitialLowercaseEntityName(CoreTool.isNotNullStr(dbTableConfAndInfoVO.getDbTablePrefix()) ? CoreTool.getInitialLowercaseHumpByUnderline(dbTableInfoVO.getDbTableName().replaceAll(dbTableConfAndInfoVO.getDbTablePrefix(), "").trim()) : CoreTool.getInitialLowercaseHumpByUnderline(dbTableInfoVO.getDbTableName()));
        dbTableConfAndInfoVO.setDbTableInfoVO(dbTableInfoVO);
        Collection<DbTableColInfoVO> dbTableColInfoVOSet = new LinkedHashSet<>();
        for (OracleDbTableColInfoVO oracleDbTableColInfoVO : oracleDbTableColInfoVOSet) {
          DbTableColInfoVO dbTableColInfoVO = new DbTableColInfoVO();
          dbTableColInfoVO.setColName(oracleDbTableColInfoVO.getColumnName().toUpperCase());
          dbTableColInfoVO.setColNameAnnotation(oracleDbTableColInfoVO.getComments());
          dbTableColInfoVO.setJavaDataType(CoreCodingConf.getJavaDataType(oracleDbTableColInfoVO.getDataType()));
          dbTableColInfoVO.setTsDataType(CoreCodingConf.getTsDataType(oracleDbTableColInfoVO.getDataType()));
          dbTableColInfoVO.setIsNull(CoreCodingConf.getIsNull(oracleDbTableColInfoVO.getNullable()));
          dbTableColInfoVO.setInitialCaseColumnName(CoreTool.getInitialCaseHumpByUnderline(dbTableColInfoVO.getColName()));
          dbTableColInfoVO.setInitialLowercaseColumnName(CoreTool.getInitialLowercaseHumpByUnderline(dbTableColInfoVO.getColName()));
          dbTableColInfoVO.setWeightOrder(oracleDbTableColInfoVO.getColumnId().longValue());
          dbTableColInfoVOSet.add(dbTableColInfoVO);
        }
        dbTableConfAndInfoVO.setDbTableColInfoVOSet(dbTableColInfoVOSet);
        DbTablePkInfoVO dbTablePkInfoVO = new DbTablePkInfoVO();
        dbTablePkInfoVO.setColName(oracleDbTablePkInfoVO.getColumnName().toUpperCase());
        for (DbTableColInfoVO dbTableColInfoVO : dbTableColInfoVOSet) {
          if (dbTablePkInfoVO.getColName().equals(dbTableColInfoVO.getColName())) {
            dbTablePkInfoVO.setColNameAnnotation(dbTableColInfoVO.getColNameAnnotation());
            dbTablePkInfoVO.setJavaDataType(dbTableColInfoVO.getJavaDataType());
            dbTablePkInfoVO.setTsDataType(dbTableColInfoVO.getTsDataType());
            dbTablePkInfoVO.setIsNull(dbTableColInfoVO.getIsNull());
            dbTablePkInfoVO.setInitialCaseColumnName(dbTableColInfoVO.getInitialCaseColumnName());
            dbTablePkInfoVO.setInitialLowercaseColumnName(dbTableColInfoVO.getInitialLowercaseColumnName());
            dbTablePkInfoVO.setWeightOrder(dbTableColInfoVO.getWeightOrder());
            break;
          }
        }
        dbTableConfAndInfoVO.setDbTablePkInfoVO(dbTablePkInfoVO);
      } else {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      dbTableConfAndInfoVO.setJdbcEntityPackageName(CoreCodingConf.getJdbcEntityPackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setJdbcEntityFilePath(CoreCodingConf.getJdbcEntityFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setQueryPackageName(CoreCodingConf.getQueryPackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setQueryFilePath(CoreCodingConf.getQueryFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setVoPackageName(CoreCodingConf.getVoPackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setVoFilePath(CoreCodingConf.getVoFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setMapperPersistentInterfacesPackageName(CoreCodingConf.getMapperPersistentInterfacesPackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setMapperPersistentInterfacesFilePath(CoreCodingConf.getMapperPersistentInterfacesFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setMapperSqlFilePath(CoreCodingConf.getMapperSqlFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setServiceInterfacesPackageName(CoreCodingConf.getServiceInterfacesPackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setServiceInterfacesFilePath(CoreCodingConf.getServiceInterfacesFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setServiceImplementPackageName(CoreCodingConf.getServiceImplementPackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setServiceImplementFilePath(CoreCodingConf.getServiceImplementFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setServicePackageName(CoreCodingConf.getServicePackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setServiceFilePath(CoreCodingConf.getServiceFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setRestPackageName(CoreCodingConf.getRestPackageName(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setRestFilePath(CoreCodingConf.getRestFilePath(dbTableConfAndInfoVO.getProjectPath(), dbTableConfAndInfoVO.getProjectModuleName(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setRestUrlNamePrefix(CoreCodingConf.getRestUrlNamePrefix(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setVueEntityFilePath(CoreCodingConf.getVueEntityFilePath(dbTableConfAndInfoVO.getProjectPathVue(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setVueQueryFilePath(CoreCodingConf.getVueQueryFilePath(dbTableConfAndInfoVO.getProjectPathVue(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setVueVoFilePath(CoreCodingConf.getVueVoFilePath(dbTableConfAndInfoVO.getProjectPathVue(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setVueApiServiceFilePath(CoreCodingConf.getVueApiServiceFilePath(dbTableConfAndInfoVO.getProjectPathVue(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName()));
      dbTableConfAndInfoVO.setVueStoreFilePath(CoreCodingConf.getVueStoreFilePath(dbTableConfAndInfoVO.getProjectPathVue(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName()));
      dbTableConfAndInfoVO.setVueViewFilePath(CoreCodingConf.getVueViewFilePath(dbTableConfAndInfoVO.getProjectPathVue(), dbTableConfAndInfoVO.getProjectModuleNameSet(), dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName()));
      dbTableConfAndInfoVO.setVueEntityFileQuotePath(CoreCodingConf.getVueEntityFileQuotePath(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setVueQueryFileQuotePath(CoreCodingConf.getVueQueryFileQuotePath(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setVueVoFileQuotePath(CoreCodingConf.getVueVoFileQuotePath(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setVueApiServiceFileQuotePath(CoreCodingConf.getVueApiServiceFileQuotePath(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      dbTableConfAndInfoVO.setVueStoreFileQuotePath(CoreCodingConf.getVueStoreFileQuotePath(dbTableConfAndInfoVO.getProjectModuleNameSet()));
      return dbTableConfAndInfoVO;
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成实体类文件
   */
  public void generateEntityFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("jdbcEntityPackageName", dbTableConfAndInfoVO.getJdbcEntityPackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("dbTableName", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableName());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/entity/jdbc/1.txt"), configMap)).append("\n");
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("javaDataType", dbTableColInfoVO.getJavaDataType());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/entity/jdbc/2.txt"), columnConfigMap)).append("\n");
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/entity/jdbc/3.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getJdbcEntityFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成查询类文件
   */
  public void generateQueryFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("queryPackageName", dbTableConfAndInfoVO.getQueryPackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("dbTableName", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableName());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/query/1.txt"), configMap)).append("\n");
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("javaDataType", dbTableColInfoVO.getJavaDataType());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/query/2.txt"), columnConfigMap)).append("\n");
      }
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        if ("String".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation() + " >>> Like");
          columnConfigMap.put("javaDataType", dbTableColInfoVO.getJavaDataType());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName() + "AndLike");
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/query/2.txt"), columnConfigMap)).append("\n");
        }
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/query/3.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getQueryFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成展示类文件
   */
  public void generateVoFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("voPackageName", dbTableConfAndInfoVO.getVoPackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("dbTableName", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableName());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/vo/1.txt"), configMap)).append("\n");
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("javaDataType", dbTableColInfoVO.getJavaDataType());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/vo/2.txt"), columnConfigMap)).append("\n");
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/vo/3.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVoFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成mapper持久化接口类文件
   */
  public void generateMapperPersistentInterfacesFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("mapperPersistentInterfacesPackageName", dbTableConfAndInfoVO.getMapperPersistentInterfacesPackageName());
      configMap.put("jdbcEntityPackageName", dbTableConfAndInfoVO.getJdbcEntityPackageName());
      configMap.put("queryPackageName", dbTableConfAndInfoVO.getQueryPackageName());
      configMap.put("voPackageName", dbTableConfAndInfoVO.getVoPackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapper/1.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getMapperPersistentInterfacesFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成mapper sql文件
   */
  public void generateMapperSqlFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("mapperPersistentInterfacesPackageName", dbTableConfAndInfoVO.getMapperPersistentInterfacesPackageName());
      configMap.put("jdbcEntityPackageName", dbTableConfAndInfoVO.getJdbcEntityPackageName());
      configMap.put("voPackageName", dbTableConfAndInfoVO.getVoPackageName());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      configMap.put("dbTableName", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableName());
      configMap.put("pkColName", dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName());
      configMap.put("pkInitialLowercaseColumnName", dbTableConfAndInfoVO.getDbTablePkInfoVO().getInitialLowercaseColumnName());
      configMap.put("sqlSave", CoreCodingConf.getSqlSave(dbTableConfAndInfoVO));
      configMap.put("sqlSaveValues", CoreCodingConf.getSqlSaveValues(dbTableConfAndInfoVO));
      configMap.put("sqlUpdate", CoreCodingConf.getSqlUpdate(dbTableConfAndInfoVO));
      configMap.put("sqlKeySearch", CoreCodingConf.getSqlKeySearch(dbTableConfAndInfoVO));
      configMap.put("sqlKeySearchVo", CoreCodingConf.getSqlKeySearchVo(dbTableConfAndInfoVO));
      configMap.put("sqlEo", CoreCodingConf.getSqlEo(dbTableConfAndInfoVO));
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/1.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        columnConfigMap.put("colName", dbTableColInfoVO.getColName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/2.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/3.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        columnConfigMap.put("colName", dbTableColInfoVO.getColName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/4.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/5.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        columnConfigMap.put("colName", dbTableColInfoVO.getColName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/6.txt"), columnConfigMap));
      }
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        if ("String".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
          columnConfigMap.put("colName", dbTableColInfoVO.getColName());
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/7.txt"), columnConfigMap));
        }
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/mapping/8.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getMapperSqlFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成服务接口类文件
   */
  public void generateServiceInterfacesFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("serviceInterfacesPackageName", dbTableConfAndInfoVO.getServiceInterfacesPackageName());
      configMap.put("jdbcEntityPackageName", dbTableConfAndInfoVO.getJdbcEntityPackageName());
      configMap.put("queryPackageName", dbTableConfAndInfoVO.getQueryPackageName());
      configMap.put("voPackageName", dbTableConfAndInfoVO.getVoPackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/service/interfaces/1.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getServiceInterfacesFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成服务实现类文件
   */
  public void generateServiceImplementFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("serviceImplementPackageName", dbTableConfAndInfoVO.getServiceImplementPackageName());
      configMap.put("jdbcEntityPackageName", dbTableConfAndInfoVO.getJdbcEntityPackageName());
      configMap.put("queryPackageName", dbTableConfAndInfoVO.getQueryPackageName());
      configMap.put("voPackageName", dbTableConfAndInfoVO.getVoPackageName());
      configMap.put("mapperPersistentInterfacesPackageName", dbTableConfAndInfoVO.getMapperPersistentInterfacesPackageName());
      configMap.put("serviceInterfacesPackageName", dbTableConfAndInfoVO.getServiceInterfacesPackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      configMap.put("initialLowercaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName());
      configMap.put("pkInitialCaseColumnName", dbTableConfAndInfoVO.getDbTablePkInfoVO().getInitialCaseColumnName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/service/implement/1.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getServiceImplementFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成服务类文件
   */
  public void generateServiceFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("servicePackageName", dbTableConfAndInfoVO.getServicePackageName());
      configMap.put("jdbcEntityPackageName", dbTableConfAndInfoVO.getJdbcEntityPackageName());
      configMap.put("queryPackageName", dbTableConfAndInfoVO.getQueryPackageName());
      configMap.put("voPackageName", dbTableConfAndInfoVO.getVoPackageName());
      configMap.put("mapperPersistentInterfacesPackageName", dbTableConfAndInfoVO.getMapperPersistentInterfacesPackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      configMap.put("initialLowercaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName());
      configMap.put("pkInitialCaseColumnName", dbTableConfAndInfoVO.getDbTablePkInfoVO().getInitialCaseColumnName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/service/1.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/service/2.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/service/3.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getServiceFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成rest接口类文件
   */
  public void generateRestFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("restPackageName", dbTableConfAndInfoVO.getRestPackageName());
      configMap.put("jdbcEntityPackageName", dbTableConfAndInfoVO.getJdbcEntityPackageName());
      configMap.put("queryPackageName", dbTableConfAndInfoVO.getQueryPackageName());
      configMap.put("voPackageName", dbTableConfAndInfoVO.getVoPackageName());
      configMap.put("servicePackageName", dbTableConfAndInfoVO.getServicePackageName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("restUrlNamePrefix", dbTableConfAndInfoVO.getRestUrlNamePrefix());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      configMap.put("initialLowercaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName());
      configMap.put("pkInitialCaseColumnName", dbTableConfAndInfoVO.getDbTablePkInfoVO().getInitialCaseColumnName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/java/rest/1.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getRestFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 删除代码文件 >>> pro
   */
  public void delProCodeFiles(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      new File(dbTableConfAndInfoVO.getJdbcEntityFilePath()).delete();
      new File(dbTableConfAndInfoVO.getQueryFilePath()).delete();
      new File(dbTableConfAndInfoVO.getVoFilePath()).delete();
      new File(dbTableConfAndInfoVO.getMapperPersistentInterfacesFilePath()).delete();
      new File(dbTableConfAndInfoVO.getMapperSqlFilePath()).delete();
//      new File(dbTableConfAndInfoVO.getServiceInterfacesFilePath()).delete();
//      new File(dbTableConfAndInfoVO.getServiceImplementFilePath()).delete();
      new File(dbTableConfAndInfoVO.getServiceFilePath()).delete();
      new File(dbTableConfAndInfoVO.getRestFilePath()).delete();
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成vue实体类文件
   */
  public void generateVueEntityFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("dbTableName", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableName());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/entity/1.txt"), configMap)).append("\n");
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("tsDataType", dbTableColInfoVO.getTsDataType());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/entity/2.txt"), columnConfigMap)).append("\n");
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/entity/3.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/entity/4.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/entity/5.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueEntityFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成vue查询类文件
   */
  public void generateVueQueryFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("dbTableName", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableName());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/query/1.txt"), configMap)).append("\n");
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("tsDataType", dbTableColInfoVO.getTsDataType());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/query/2.txt"), columnConfigMap)).append("\n");
      }
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        if ("String".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation() + " >>> Like");
          columnConfigMap.put("tsDataType", dbTableColInfoVO.getTsDataType());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName() + "AndLike");
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/query/2.txt"), columnConfigMap)).append("\n");
        }
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/query/3.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/query/4.txt"), columnConfigMap));
      }
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        if ("String".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName() + "AndLike");
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/query/4.txt"), columnConfigMap));
        }
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/query/5.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueQueryFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成vue展示类文件
   */
  public void generateVueVoFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("dbTableName", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableName());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/vo/1.txt"), configMap)).append("\n");
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("tsDataType", dbTableColInfoVO.getTsDataType());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/vo/2.txt"), columnConfigMap)).append("\n");
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/vo/3.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/vo/4.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/vo/5.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueVoFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成vue api服务类文件
   */
  public void generateVueApiServiceFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("vueEntityFileQuotePath", dbTableConfAndInfoVO.getVueEntityFileQuotePath());
      configMap.put("vueQueryFileQuotePath", dbTableConfAndInfoVO.getVueQueryFileQuotePath());
      configMap.put("vueVoFileQuotePath", dbTableConfAndInfoVO.getVueVoFileQuotePath());
      configMap.put("restUrlNamePrefix", dbTableConfAndInfoVO.getRestUrlNamePrefix());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      configMap.put("initialLowercaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/api/1.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueApiServiceFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成vue store文件
   */
  public void generateVueStoreFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("vueEntityFileQuotePath", dbTableConfAndInfoVO.getVueEntityFileQuotePath());
      configMap.put("vueQueryFileQuotePath", dbTableConfAndInfoVO.getVueQueryFileQuotePath());
      configMap.put("vueVoFileQuotePath", dbTableConfAndInfoVO.getVueVoFileQuotePath());
      configMap.put("vueApiServiceFileQuotePath", dbTableConfAndInfoVO.getVueApiServiceFileQuotePath());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      configMap.put("initialLowercaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/store/1.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueStoreFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 生成vue页面文件
   */
  public void generateVueViewFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      LinkedHashMap<String, String> configMap = new LinkedHashMap<String, String>();
      configMap.putAll(dbTableConfAndInfoVO.getConfMap());
      configMap.put("initialLowercaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialLowercaseEntityName());
      configMap.put("dbTableNameAnnotation", dbTableConfAndInfoVO.getDbTableInfoVO().getDbTableNameAnnotation());
      configMap.put("initialCaseEntityName", dbTableConfAndInfoVO.getDbTableInfoVO().getInitialCaseEntityName());
      configMap.put("vueEntityFileQuotePath", dbTableConfAndInfoVO.getVueEntityFileQuotePath());
      configMap.put("vueQueryFileQuotePath", dbTableConfAndInfoVO.getVueQueryFileQuotePath());
      configMap.put("vueVoFileQuotePath", dbTableConfAndInfoVO.getVueVoFileQuotePath());
      configMap.put("vueStoreFileQuotePath", dbTableConfAndInfoVO.getVueStoreFileQuotePath());
      configMap.put("pkInitialLowercaseColumnName", dbTableConfAndInfoVO.getDbTablePkInfoVO().getInitialLowercaseColumnName());
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/1.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        if ("String".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName() + "AndLike");
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/2.txt"), columnConfigMap));
        } else if ("Long".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/3.txt"), columnConfigMap));
        }
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/4.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        if ("String".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/5.txt"), columnConfigMap));
        } else if ("Long".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/6.txt"), columnConfigMap));
        }
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/7.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/8.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/9.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/10.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/11.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        if ("String".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/12.txt"), columnConfigMap));
        } else if ("Long".equals(dbTableColInfoVO.getJavaDataType())) {
          LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
          columnConfigMap.putAll(configMap);
          columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
          columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
          fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/13.txt"), columnConfigMap));
        }
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/14.txt"), configMap));
      for (DbTableColInfoVO dbTableColInfoVO : dbTableConfAndInfoVO.getDbTableColInfoVOSet()) {
        if (dbTableConfAndInfoVO.getDbTablePkInfoVO().getColName().equals(dbTableColInfoVO.getColName())) {
          continue;
        }
        LinkedHashMap<String, String> columnConfigMap = new LinkedHashMap<String, String>();
        columnConfigMap.putAll(configMap);
        columnConfigMap.put("colNameAnnotation", dbTableColInfoVO.getColNameAnnotation());
        columnConfigMap.put("initialLowercaseColumnName", dbTableColInfoVO.getInitialLowercaseColumnName());
        fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/15.txt"), columnConfigMap));
      }
      fileStr.append(CoreTool.renderString(CoreTool.getStrByFileResourcesPath("/vue/view/16.txt"), configMap));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueViewFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 删除代码文件 >>> vue
   */
  public void delVueCodeFiles(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      new File(dbTableConfAndInfoVO.getVueEntityFilePath()).delete();
      new File(dbTableConfAndInfoVO.getVueQueryFilePath()).delete();
      new File(dbTableConfAndInfoVO.getVueVoFilePath()).delete();
      new File(dbTableConfAndInfoVO.getVueApiServiceFilePath()).delete();
      new File(dbTableConfAndInfoVO.getVueStoreFilePath()).delete();
      new File(dbTableConfAndInfoVO.getVueViewFilePath()).delete();
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 重新生成查询类文件
   */
  public void regenerateQueryFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      String oldFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getQueryFilePath());
      this.generateQueryFile(dbTableConfAndInfoVO);
      String newFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getQueryFilePath());
      fileStr.append(newFileStr.substring(0, newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(oldFileStr.substring(0, oldFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getQueryFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 重新生成展示类文件
   */
  public void regenerateVoFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      String oldFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getVoFilePath());
      this.generateVoFile(dbTableConfAndInfoVO);
      String newFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getVoFilePath());
      fileStr.append(newFileStr.substring(0, newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(oldFileStr.substring(0, oldFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVoFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 重新生成mapper sql文件
   */
  public void regenerateMapperSqlFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      String oldFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getMapperSqlFilePath());
      this.generateMapperSqlFile(dbTableConfAndInfoVO);
      String newFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getMapperSqlFilePath());
      fileStr.append(newFileStr.substring(0, newFileStr.indexOf(CoreCodingConf.againGenerateXmlKey) + 66));
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateXmlKey) + 66);
      fileStr.append(oldFileStr.substring(0, oldFileStr.indexOf(CoreCodingConf.againGenerateXmlKey)));
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateXmlKey) + 66);
      fileStr.append(newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateXmlKey)));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getMapperSqlFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 重新生成vue查询类文件
   */
  public void regenerateVueQueryFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      String oldFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getVueQueryFilePath());
      this.generateVueQueryFile(dbTableConfAndInfoVO);
      String newFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getVueQueryFilePath());
      fileStr.append(newFileStr.substring(0, newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(oldFileStr.substring(0, oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(newFileStr.substring(0, newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(oldFileStr.substring(0, oldFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueQueryFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

  /**
   * 重新生成vue展示类文件
   */
  public void regenerateVueVoFile(DbTableConfAndInfoVO dbTableConfAndInfoVO) throws Exception {
    try {
      if (CoreTool.isNullEo(dbTableConfAndInfoVO)) {
        throw new CoreException(CoreException.E_PARAM_ERR);
      }
      StringBuilder fileStr = new StringBuilder();
      String oldFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getVueVoFilePath());
      this.generateVueVoFile(dbTableConfAndInfoVO);
      String newFileStr = CoreTool.getContentStrByFilePath(dbTableConfAndInfoVO.getVueVoFilePath());
      fileStr.append(newFileStr.substring(0, newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(oldFileStr.substring(0, oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(newFileStr.substring(0, newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66));
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      oldFileStr = oldFileStr.substring(oldFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(oldFileStr.substring(0, oldFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      newFileStr = newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey) + 66);
      fileStr.append(newFileStr.substring(newFileStr.indexOf(CoreCodingConf.againGenerateKey)));
      CoreTool.getFileByContentStrAndPath(fileStr.toString(), dbTableConfAndInfoVO.getVueVoFilePath());
    } catch (Exception e) {
      if (log.isDebugEnabled()) {
        log.error(e.getMessage(), e);
      }
      throw e;
    }
  }

}
